﻿using ArtMath.CommonType;
using ArtMath.Core.Helper;
using ArtMath.Flag;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;

namespace ArtMath.Administrator
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            //Process main = Utility.GetProcess($"{Flags.SoftwareName}.Window");
            //if (main != null)
            //{
            //    byte[] b = Encoding.Default.GetBytes(Handle.ToString());
            //    MessageContent msg = new MessageContent()
            //    {
            //        dwData = new IntPtr(250),
            //        cbData = b.Length + 1,
            //        lpData = Handle.ToString(),
            //    };
            //    Utility.SendMessage(main.MainWindowHandle, Flags.WM_COPYDATA, IntPtr.Zero, ref msg);
            //}
        }
        protected override void OnShown(EventArgs e)
        {
            Text = Handle.ToString();
            base.OnShown(e);
        }
        protected override void DefWndProc(ref Message m)
        {
            switch (m.Msg)
            {
                case Flags.WM_COPYDATA:
                    MessageContent msg = (MessageContent)m.GetLParam(typeof(MessageContent));
                    //msg.Invoke();
                    //BackColor = (Color)msg.Params[0];
                    Text = msg.lpData;
                    break;
                default:
                    base.DefWndProc(ref m);
                    break;
            }
        }
    }
}
